/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package com.fzhucc.modules.thinktank.controller;

import com.fzhucc.annotation.Log;
import com.fzhucc.modules.pms.domain.dto.ProjectExpertScoreDto;
import com.fzhucc.modules.technical.domain.dto.TechnicalProjectDistributionDto;
import com.fzhucc.modules.thinktank.domain.AcademicianProjectLog;
import com.fzhucc.modules.thinktank.domain.dto.AcademicianProjectDistributionDto;
import com.fzhucc.modules.thinktank.service.AcademicianProjectLogService;
import com.fzhucc.modules.thinktank.domain.dto.AcademicianProjectLogQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

/**
 * @author yyg
 * @date 2023-01-03
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "智库：院士之家项目管理")
@RequestMapping("/api/academicianProjectLog")
public class AcademicianProjectLogController {

    private final AcademicianProjectLogService academicianProjectLogService;



    @GetMapping
    @Log("查询academicianProjectLog")
    @ApiOperation("查询academicianProjectLog")
    @PreAuthorize("@el.check('academicianProjectLog:list')")
    public ResponseEntity<Object> queryAcademicianProjectLog(AcademicianProjectLogQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity<>(academicianProjectLogService.queryAll(criteria,pageable), HttpStatus.OK);
    }


    @Log("项目分配院士之家")
    @ApiOperation("项目分配院士之家")
    @PostMapping("/distribution")
    @PreAuthorize("@el.check('academicianProjectLog:list')")
    public ResponseEntity<Object> distribution(@RequestBody AcademicianProjectDistributionDto academicianProjectDistributionDto){
        academicianProjectLogService.dodistribution(academicianProjectDistributionDto);
        return new ResponseEntity<>(HttpStatus.OK);
    }


    @Log("院士之家查询已分配自己的项目")
    @ApiOperation("院士之家查询已分配自己的项目")
    @GetMapping("/getAcademicianProjectByLoginUser")
    @PreAuthorize("@el.check('academicianProjectLog:list')")
    public ResponseEntity<Object> getAcademicianProjectByLoginUser(Pageable pageable){
        return new ResponseEntity<>(academicianProjectLogService.getAcademicianProjectByLoginUser(pageable), HttpStatus.OK);
    }


    @Log("通过项目查询院士之家列表")
    @ApiOperation("通过项目查询院士之家列表")
    @GetMapping("/getAcademicianByProjectId")
    @PreAuthorize("@el.check('academicianProjectLog:list')")
    public ResponseEntity<Object> getAcademicianByProjectId(String projectId){
        return new ResponseEntity<>(academicianProjectLogService.getAcademicianByProjectId(projectId), HttpStatus.OK);
    }

    @Log("查询已分配自己的项目")
    @ApiOperation("查询已分配自己的项目")
    @GetMapping("/getProjectByLoginUser")
    public ResponseEntity<Object> getProjectByLoginUser(Pageable pageable){
        return new ResponseEntity<>(academicianProjectLogService.getProjectByLoginUser(pageable), HttpStatus.OK);
    }

    @Log("院士之家专家评分")
    @ApiOperation("院士之家专家评分")
    @PostMapping("/expertRating")
    @PreAuthorize("@el.check('academicianProjectLog:list')")
    public ResponseEntity<Object> expertRating(@RequestBody ProjectExpertScoreDto projectExpertScoreDto){
        academicianProjectLogService.expertRating(projectExpertScoreDto);
        return new ResponseEntity<>(HttpStatus.OK);
    }

    @Log("查询单个项目的院士之家专家评分情况")
    @ApiOperation("查询单个项目的院士之家专家评分情况")
    @GetMapping("/getProjectScoreByProjectId")
    public ResponseEntity<Object> getProjectScoreByProjectId(String projectId){
        return new ResponseEntity<>(academicianProjectLogService.getProjectScoreByProjectId(projectId),HttpStatus.OK);
    }

    @Log("查询单个项目的院士之家专家评分情况 区分项目等级阶段")
    @ApiOperation("查询单个项目的院士之家专家评分情况 区分项目等级阶段")
    @GetMapping("/getProjectScoreByProjectIdSiftLevel")
    public ResponseEntity<Object> getProjectScoreByProjectIdSiftLevel(String projectId){
        return new ResponseEntity<>(academicianProjectLogService.getProjectScoreByProjectIdSiftLevel(projectId),HttpStatus.OK);
    }

    @Log("查询单个项目是否院士之家评分")
    @ApiOperation("查询单个项目是否院士之家评分")
    @GetMapping("/getIsScoreByProjectId")
    public ResponseEntity<Object> getIsScoreByProjectId(String projectId){
        return new ResponseEntity<>(academicianProjectLogService.getIsScoreByProjectId(projectId),HttpStatus.OK);
    }


    @Log("查询单个项目的登录用户院士之家专家评分情况  包含所有的项目等级阶段评分")
    @ApiOperation("查询单个项目的登录用户院士之家专家评分情况  包含所有的项目等级阶段评分")
    @GetMapping("/getByProjectIdAndLoginUser")
    public ResponseEntity<Object> getByProjectIdAndLoginUser(String projectId){
        return new ResponseEntity<>(academicianProjectLogService.getByProjectIdAndLoginUser(projectId),HttpStatus.OK);
    }

    @Log("查询单个项目的登录用户院士之家专家评分情况  区分项目等级阶段评分")
    @ApiOperation("查询单个项目的登录用户院士之家专家评分情况  区分项目等级阶段评分")
    @GetMapping("/getByProjectIdAndLoginUserSiftLevel")
    public ResponseEntity<Object> getByProjectIdAndLoginUserSiftLevel(String projectId){
        return new ResponseEntity<>(academicianProjectLogService.getByProjectIdAndLoginUserSiftLevel(projectId),HttpStatus.OK);
    }

}